import json
import inspect
from django.http import HttpResponse
from django.shortcuts import render,redirect
from port import jsonpost
from ajax import get_global

from django.contrib.auth import authenticate, login
from django.contrib import auth

def production_kanban(request):
    return render(request,'production_kanban.html')

def ajax_view(request):
    if request.method=='POST':
        try:
            return jsonpost(request, get_global())
        except KeyError as e:
            rt={'status':'error','msg':'key error '+str(e) +' \n may function name error'}
            return HttpResponse(json.dumps(rt),content_type="application/json")


def simple_login(request):
    #user = authenticate(username='heyulin', password='12345')
    user, _ = auth.models.User.objects.get_or_create(username='heyulin')
    user.backend = 'django.contrib.auth.backends.ModelBackend'
    login(request, user)
    return redirect('/production_kanban')











